In the present work, for the first time, mixed convection heat transfer of nanofluid in a uniform magnetic field inside a LID-DRIVEN K-shaped CAVITY is simulated via lattice Boltzmann method. Both left and right walls are maintained at constant cold temperature. The bottom-horizontal wall is maintained at constant hot temperature. Temperature on the top-horizontal wall is varied linearly. All quantities of both flow and temperature field are calculated by flow and temperature distribution functions. The effects of different parameters such as Reynolds number (50-200), Hartman number (0-60), aspect ratio of the K-shaped CAVITY (0. 4-1), nanoparticle volume fraction (0-0. 05) on mixed convective heat transfer are investigated. The obtained result show that for a fixed Hartman number, increase in aspect ratio and Reynolds number causes increase in heat transfer. Also in a fixed Reynolds number and aspect ratio, increasing of Hartman number decreases velocity of flow and heat transfer. In addition, changing solid volume fraction can affect heat transfer directly.